# !/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time        : 2021/9/18 17:54
@Author      : Albert Darren
@Contact     : 2563491540@qq.com
@File        : pil_convert.py
@Version     : Version 1.0.0
@Description : TODO
@Created By  : PyCharm
"""
from PIL import Image
from matplotlib import pyplot as plt
plt.subplots_adjust(wspace=0.5)
im = Image.open("./../experiment_fig/aio.jpg")
for i in range(1, 9):
    color_num = 2 ** i
    converted_im = im.convert(mode="P",
                              palette=Image.ADAPTIVE, colors=color_num)
    plt.subplot(2, 4, 9-i)
    plt.title("colors="+str(color_num))
    plt.imshow(converted_im)

plt.show()
